<template>
    <div class="list-com">
        <navTitle title='كۆرگەنلىرىم'></navTitle>
        <navTab :tabIndex='tabIndex' @setTabIndex="setTabIndex"></navTab>
        <scroll>
            <div class="box">
                <gridList :list='list' :isShowQisim="false" :isShowDesc="false"></gridList>
            </div>
        </scroll>
    </div>
</template>

<script>
    import {
        getListData
    } from '@/api/user.js'
    import gridList from '@/components/custom/gridList.vue'
    import navTitle from '@/components/custom/navTitle.vue'
    import navTab from '@/components/list/navTab.vue'
    import scroll from '@/components/list/scroll.vue'
    export default {
        components: {
            navTitle,
            scroll,
            navTab,
            gridList,
        },
        data() {
            return {
                tabIndex: 0,
                list: [],
            }
        },
        async mounted() {
            this.getList()
        },
        methods: {
            async getList() {
                this.$emit('setLoading', true)
                const res = await getListData()
                if (res) {
                    // console.log(res);
                    if (this.tabIndex == 0) {
                        this.list = res.data.data.myView
                        // console.log(this.list);
                    } else {
                        this.list = res.data.data.myLike.data
                        // console.log(this.list);
                    }
                } else {
                    uni.showToast({
                        title: '请求失败',
                        icon: 'error'
                    })
                }
                this.$emit('setLoading', false)
            },
            setTabIndex(tabIndex) {
                this.tabIndex = tabIndex
                this.getList()
            },
        },
    }
</script>

<style lang="scss" scoped>
    .list-com {
        .box {
            padding: 10px 0;
        }
    }
</style>